
<%@page import="java.io.File"%>
<%@page import="java.io.FileInputStream"%>
<%@page import="java.io.FileOutputStream"%>
<%@page import="java.io.IOException"%>
<%@page import="java.io.InputStream"%>
<%@page import="java.sql.Timestamp"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Arrays"%>
<%@page import="java.util.Calendar"%>
<%@page import="java.util.Date"%>
<%@page import="java.util.List"%>
<%@page import="java.util.TimeZone"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="org.apache.log4j.Logger"%>
<%@page import="org.apache.poi.hssf.usermodel.HSSFWorkbook"%>
<%@page import="org.apache.poi.ss.usermodel.Cell"%>
<%@page import="org.apache.poi.ss.usermodel.CreationHelper"%>
<%@page import="org.apache.poi.ss.usermodel.Row"%>
<%@page import="org.apache.poi.ss.usermodel.Sheet"%>
<%@page import="org.apache.poi.ss.usermodel.Workbook"%>
<%@page import="org.apache.poi.ss.usermodel.WorkbookFactory"%>
<%@page import="org.apache.poi.xssf.usermodel.XSSFWorkbook"%>
<%@page import="wt.change2.WTChangeOrder2"%>
<%@page import="wt.doc.WTDocument"%>
<%@page import="wt.fc.ObjectIdentifier"%>
<%@page import="wt.fc.ObjectReference"%>
<%@page import="wt.fc.PersistenceHelper"%>
<%@page import="wt.fc.PersistenceServerHelper"%>
<%@page import="wt.fc.QueryResult"%>
<%@page import="wt.log4j.LogR"%>
<%@page import="wt.method.RemoteMethodServer"%>
<%@page import="wt.part.WTPart"%>
<%@page import="wt.pds.StatementSpec"%>
<%@page import="wt.query.ClassAttribute"%>
<%@page import="wt.query.QuerySpec"%>
<%@page import="wt.query.SearchCondition"%>
<%@page import="wt.query.WhereExpression"%>
<%@page import="wt.util.WTException"%>
<%@page import="wt.util.WTProperties"%>
<%@page import="wt.vc.config.LatestConfigSpec"%>
<%@page import="wt.vc.views.View"%>
<%@page import="wt.vc.views.ViewHelper"%>
<%@page import="wt.vc.views.ViewManageable"%>
<%@page import="com.ptc.core.meta.type.mgmt.server.impl.WTTypeDefinition"%>
<%@page import="com.ptc.core.meta.type.mgmt.server.impl.WTTypeDefinitionMaster"%>


<%


List<String>result = new ArrayList<String>();
String yestoday="";
System.out.println("[Kiranote] findFRUSPPartListYestoday yestoday:" + yestoday);
//get Part created or modified yestoday.
Date currentDateTime = new Date();
System.out.println("currentDateTime : " + currentDateTime);
//Calculate date by GMT +8

/* Date trsferdDate = trsferDateTimeZone(currentDateTime, TimeZone.getTimeZone("GMT"),
        
        TimeZone.getTimeZone("Asia/Shanghai")); */
Date trsferdDate = null;
if (currentDateTime != null) {
    int timeOffset = TimeZone.getTimeZone("GMT").getRawOffset() - TimeZone.getTimeZone("Asia/Shanghai").getRawOffset();
    trsferdDate = new Date(currentDateTime.getTime() - timeOffset);
}
Calendar cal = Calendar.getInstance();
cal.setTime(trsferdDate);
cal.set(Calendar.DATE, 0);

SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd");
String trsferdDateStr = sdfDate.format(cal.getTime());
System.out.println("trsferdDateStr : " + trsferdDateStr);
 yestoday = trsferdDateStr;



String softType = "wt.part.WTPart|com.lenovo.LPart";




QuerySpec querySpec = new QuerySpec(WTPart.class);
// Modified Data-->Yestoday
Timestamp start = getGMTTimestamp(yestoday, "00:00:00", TimeZone.getTimeZone("Asia/Shanghai"));
int indexWTPart = querySpec.appendClassList(WTPart.class, true);
querySpec.appendWhere(new SearchCondition(WTPart.class,
        WTPart.MODIFY_TIMESTAMP, SearchCondition.GREATER_THAN_OR_EQUAL, start), new int[indexWTPart]);
querySpec.appendAnd();
Timestamp end = getGMTTimestamp(yestoday, "23:59:59", TimeZone.getTimeZone("Asia/Shanghai"));
System.out.println("[Kiranote] findPartModifiedYestoday,start:" + start + ",end:" + end);
querySpec.appendWhere(new SearchCondition(WTPart.class,
        WTPart.MODIFY_TIMESTAMP, SearchCondition.LESS_THAN_OR_EQUAL, end), new int[indexWTPart]);
// SoftType-->LPart
if (softType != null && !"".equals(softType)) {
    WhereExpression where = null;
    int indexWTTypeDefinition = querySpec.appendClassList(WTTypeDefinition.class, false);
    int indexWTTypeDefinitionMaster = querySpec.appendClassList(WTTypeDefinitionMaster.class, false);
    where = new SearchCondition(new ClassAttribute(WTPart.class, "typeDefinitionReference.key.id"),
            SearchCondition.EQUAL, new ClassAttribute(WTTypeDefinition.class,
                    "thePersistInfo.theObjectIdentifier.id"));
    querySpec.appendAnd();
    querySpec.appendWhere(where, new int[] { indexWTPart, indexWTTypeDefinition });

    where = new SearchCondition(new ClassAttribute(WTTypeDefinition.class, "masterReference.key.id"),
            SearchCondition.EQUAL, new ClassAttribute(WTTypeDefinitionMaster.class,
                    "thePersistInfo.theObjectIdentifier.id"));
    querySpec.appendAnd();
    querySpec.appendWhere(where, new int[] { indexWTTypeDefinition, indexWTTypeDefinitionMaster });

    where = new SearchCondition(WTTypeDefinitionMaster.class, "intHid", SearchCondition.EQUAL,
            softType);
    querySpec.appendAnd();
    querySpec.appendWhere(where, new int[] { indexWTTypeDefinitionMaster });

}
QueryResult qr = PersistenceServerHelper.manager
        .query(querySpec);
System.out.println("[Kiranote] findPartModifiedYestoday,qr:" + qr.toString());

if (qr != null) {
    LatestConfigSpec configSpec = new LatestConfigSpec();
    qr = configSpec.process(qr);
}






%>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
